package com.example.ruomi.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Data;

/**
 * 存储用户的歌单信息
 * @TableName playlists
 */
@TableName(value ="playlists")
@Data
public class Playlists {
    /**
     * 歌单ID
     */
    @TableId(value = "playlist_id", type = IdType.AUTO)
    private Integer playlistId;

    /**
     * 创建者的用户ID
     */
    @TableField(value = "user_id")
    private Integer userId;

    /**
     * 歌单名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 歌单描述
     */
    @TableField(value = "description")
    private String description;

    /**
     * 封面图片URL
     */
    @TableField(value = "cover_image_url")
    private String coverImageUrl;

    /**
     * 创建时间，默认当前时间
     */
    @TableField(value = "created_at")
    private Date createdAt;

    /**
     * 更新时间，默认当前时间并自动更新
     */
    @TableField(value = "updated_at")
    private Date updatedAt;

    /**
     * 是否公开，默认公开
     */
    @TableField(value = "is_public")
    private Integer isPublic;

    /**
     * 播放次数，默认为0
     */
    @TableField(value = "play_count")
    private Integer playCount;

    /**
     * 收藏次数，默认为0
     */
    @TableField(value = "likes_count")
    private Integer likesCount;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Playlists other = (Playlists) that;
        return (this.getPlaylistId() == null ? other.getPlaylistId() == null : this.getPlaylistId().equals(other.getPlaylistId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
            && (this.getCoverImageUrl() == null ? other.getCoverImageUrl() == null : this.getCoverImageUrl().equals(other.getCoverImageUrl()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
            && (this.getIsPublic() == null ? other.getIsPublic() == null : this.getIsPublic().equals(other.getIsPublic()))
            && (this.getPlayCount() == null ? other.getPlayCount() == null : this.getPlayCount().equals(other.getPlayCount()))
            && (this.getLikesCount() == null ? other.getLikesCount() == null : this.getLikesCount().equals(other.getLikesCount()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getPlaylistId() == null) ? 0 : getPlaylistId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        result = prime * result + ((getCoverImageUrl() == null) ? 0 : getCoverImageUrl().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        result = prime * result + ((getIsPublic() == null) ? 0 : getIsPublic().hashCode());
        result = prime * result + ((getPlayCount() == null) ? 0 : getPlayCount().hashCode());
        result = prime * result + ((getLikesCount() == null) ? 0 : getLikesCount().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", playlistId=").append(playlistId);
        sb.append(", userId=").append(userId);
        sb.append(", name=").append(name);
        sb.append(", description=").append(description);
        sb.append(", coverImageUrl=").append(coverImageUrl);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", isPublic=").append(isPublic);
        sb.append(", playCount=").append(playCount);
        sb.append(", likesCount=").append(likesCount);
        sb.append("]");
        return sb.toString();
    }
}